package com.cloud.mybatis.controller;

import com.cloud.mybatis.entity.UserEntity;
import com.cloud.mybatis.service.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class MybatisController {
    @Autowired
    private UsersService usersService;

    @GetMapping("/mybatis/select")
    public List<UserEntity> select() {
        return usersService.getList();
    }

    @GetMapping("/mybatis/insert")
    public void insert() {

        UserEntity userEntity = new UserEntity();
        userEntity.setName("zhangsan");
        usersService.add(userEntity);
    }

    @GetMapping("/mybatis/test/insert")
    public void testInsert() {

        usersService.test();
    }


}